$(document).ready(function(){
	var selItem = document.getElementById("sort_select");
	var temp = selItem.options[selItem.selectedIndex].text;
	
	display(temp);
	
	//$("#item_category_span").hide();
	$("#sort_select").change(function(){
		selItem = document.getElementById("sort_select");
		temp = selItem.options[selItem.selectedIndex].text;
		
		display(temp);
		/*if(temp == "Category"){
			$("#input_query").hide();
			$("#item_category_span").show();
		}else{
			$("#item_category_span").hide();
			$("#input_query").show();
		}*/
	});
})

function display(sort){
	if(sort == "Category"){
		$("#input_query").hide();
		$("#item_category_span").show();
	}else{
		$("#item_category_span").hide();
		$("#input_query").show();
	}
}

// check whether at least one checkbox is checked
function checkItem(){
	if(document.edit_item.elements['updateItem[]']){
		if(document.edit_item.elements['updateItem[]'].length){ // if there are multiple lines
			for(var i=0;i<document.edit_item.elements.length;i++){
				if((document.edit_item.elements[i].name == "updateItem[]") && (document.edit_item.elements[i].checked)){
					return true;
				}
			}
		}else{ // if the result contains single line
			if(document.edit_item.elements['updateItem[]'].checked){
				return true;
			}
		}
	}
	alert("ERROR: No checkbox is checked.");
	return false;
}